﻿#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.5420
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace VocabManager.DataLayer
{
	using System.Data.Linq;
	using System.Data.Linq.Mapping;
	using System.Data;
	using System.Collections.Generic;
	using System.Reflection;
	using System.Linq;
	using System.Linq.Expressions;
	using System.ComponentModel;
	using System;
	
	
	public partial class FlashCardContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertCard(Card instance);
    partial void UpdateCard(Card instance);
    partial void DeleteCard(Card instance);
    partial void InsertDeck(Deck instance);
    partial void UpdateDeck(Deck instance);
    partial void DeleteDeck(Deck instance);
    #endregion
		
		public FlashCardContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		

		
		public FlashCardContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
 
		
		public System.Data.Linq.Table<Card> Cards
		{
			get
			{
				return this.GetTable<Card>();
			}
		}
		
		public System.Data.Linq.Table<Deck> Decks
		{
			get
			{
				return this.GetTable<Deck>();
			}
		}
	}
	
	[Table(Name="Cards")]
	public partial class Card : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _FrontText;
		
		private string _BackText;
		
		private string _FrontBrush;
		
		private string _BackBrush;
		
		private int _DeckId;
		
		private string _FrontImage;
		
		private string _BackImage;
		
		private string _FrontSound;
		
		private string _BackSound;
		
		private string _BackTextBrush;
		
		private string _FrontTextBrush;
		
		private System.DateTime _CreationTime;
		
		private System.DateTime _LastModifiedTime;
		
		private EntityRef<Deck> _Deck;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnFrontTextChanging(string value);
    partial void OnFrontTextChanged();
    partial void OnBackTextChanging(string value);
    partial void OnBackTextChanged();
    partial void OnFrontBrushChanging(string value);
    partial void OnFrontBrushChanged();
    partial void OnBackBrushChanging(string value);
    partial void OnBackBrushChanged();
    partial void OnDeckIdChanging(int value);
    partial void OnDeckIdChanged();
    partial void OnFrontImageChanging(string value);
    partial void OnFrontImageChanged();
    partial void OnBackImageChanging(string value);
    partial void OnBackImageChanged();
    partial void OnFrontSoundChanging(string value);
    partial void OnFrontSoundChanged();
    partial void OnBackSoundChanging(string value);
    partial void OnBackSoundChanged();
    partial void OnBackTextBrushChanging(string value);
    partial void OnBackTextBrushChanged();
    partial void OnFrontTextBrushChanging(string value);
    partial void OnFrontTextBrushChanged();
    partial void OnCreationTimeChanging(System.DateTime value);
    partial void OnCreationTimeChanged();
    partial void OnLastModifiedTimeChanging(System.DateTime value);
    partial void OnLastModifiedTimeChanged();
    #endregion
		
		public Card()
		{
			this._Deck = default(EntityRef<Deck>);
			OnCreated();
		}
		
		[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int Id
		{
			get
			{
				return this._Id;
			}
			set
			{
				if ((this._Id != value))
				{
					this.OnIdChanging(value);
					this.SendPropertyChanging();
					this._Id = value;
					this.SendPropertyChanged("Id");
					this.OnIdChanged();
				}
			}
		}
		
		[Column(Storage="_FrontText", DbType="NVarChar(4000)")]
		public string FrontText
		{
			get
			{
				return this._FrontText;
			}
			set
			{
				if ((this._FrontText != value))
				{
					this.OnFrontTextChanging(value);
					this.SendPropertyChanging();
					this._FrontText = value;
					this.SendPropertyChanged("FrontText");
					this.OnFrontTextChanged();
				}
			}
		}
		
		[Column(Storage="_BackText", DbType="NVarChar(4000)")]
		public string BackText
		{
			get
			{
				return this._BackText;
			}
			set
			{
				if ((this._BackText != value))
				{
					this.OnBackTextChanging(value);
					this.SendPropertyChanging();
					this._BackText = value;
					this.SendPropertyChanged("BackText");
					this.OnBackTextChanged();
				}
			}
		}
		
		[Column(Storage="_FrontBrush", DbType="NVarChar(4000)")]
		public string FrontBrush
		{
			get
			{
				return this._FrontBrush;
			}
			set
			{
				if ((this._FrontBrush != value))
				{
					this.OnFrontBrushChanging(value);
					this.SendPropertyChanging();
					this._FrontBrush = value;
					this.SendPropertyChanged("FrontBrush");
					this.OnFrontBrushChanged();
				}
			}
		}
		
		[Column(Storage="_BackBrush", DbType="NVarChar(4000)")]
		public string BackBrush
		{
			get
			{
				return this._BackBrush;
			}
			set
			{
				if ((this._BackBrush != value))
				{
					this.OnBackBrushChanging(value);
					this.SendPropertyChanging();
					this._BackBrush = value;
					this.SendPropertyChanged("BackBrush");
					this.OnBackBrushChanged();
				}
			}
		}
		
		[Column(Storage="_DeckId", DbType="Int NOT NULL")]
		public int DeckId
		{
			get
			{
				return this._DeckId;
			}
			set
			{
				if ((this._DeckId != value))
				{
					if (this._Deck.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnDeckIdChanging(value);
					this.SendPropertyChanging();
					this._DeckId = value;
					this.SendPropertyChanged("DeckId");
					this.OnDeckIdChanged();
				}
			}
		}
		
		[Column(Storage="_FrontImage", DbType="NVarChar(4000)")]
		public string FrontImage
		{
			get
			{
				return this._FrontImage;
			}
			set
			{
				if ((this._FrontImage != value))
				{
					this.OnFrontImageChanging(value);
					this.SendPropertyChanging();
					this._FrontImage = value;
					this.SendPropertyChanged("FrontImage");
					this.OnFrontImageChanged();
				}
			}
		}
		
		[Column(Storage="_BackImage", DbType="NVarChar(4000)")]
		public string BackImage
		{
			get
			{
				return this._BackImage;
			}
			set
			{
				if ((this._BackImage != value))
				{
					this.OnBackImageChanging(value);
					this.SendPropertyChanging();
					this._BackImage = value;
					this.SendPropertyChanged("BackImage");
					this.OnBackImageChanged();
				}
			}
		}
		
		[Column(Storage="_FrontSound", DbType="NVarChar(4000)")]
		public string FrontSound
		{
			get
			{
				return this._FrontSound;
			}
			set
			{
				if ((this._FrontSound != value))
				{
					this.OnFrontSoundChanging(value);
					this.SendPropertyChanging();
					this._FrontSound = value;
					this.SendPropertyChanged("FrontSound");
					this.OnFrontSoundChanged();
				}
			}
		}
		
		[Column(Storage="_BackSound", DbType="NVarChar(4000)")]
		public string BackSound
		{
			get
			{
				return this._BackSound;
			}
			set
			{
				if ((this._BackSound != value))
				{
					this.OnBackSoundChanging(value);
					this.SendPropertyChanging();
					this._BackSound = value;
					this.SendPropertyChanged("BackSound");
					this.OnBackSoundChanged();
				}
			}
		}
		
		[Column(Storage="_BackTextBrush", DbType="NVarChar(4000)")]
		public string BackTextBrush
		{
			get
			{
				return this._BackTextBrush;
			}
			set
			{
				if ((this._BackTextBrush != value))
				{
					this.OnBackTextBrushChanging(value);
					this.SendPropertyChanging();
					this._BackTextBrush = value;
					this.SendPropertyChanged("BackTextBrush");
					this.OnBackTextBrushChanged();
				}
			}
		}
		
		[Column(Storage="_FrontTextBrush", DbType="NVarChar(4000)")]
		public string FrontTextBrush
		{
			get
			{
				return this._FrontTextBrush;
			}
			set
			{
				if ((this._FrontTextBrush != value))
				{
					this.OnFrontTextBrushChanging(value);
					this.SendPropertyChanging();
					this._FrontTextBrush = value;
					this.SendPropertyChanged("FrontTextBrush");
					this.OnFrontTextBrushChanged();
				}
			}
		}
		
		[Column(Storage="_CreationTime", DbType="DateTime NOT NULL")]
		public System.DateTime CreationTime
		{
			get
			{
				return this._CreationTime;
			}
			set
			{
				if ((this._CreationTime != value))
				{
					this.OnCreationTimeChanging(value);
					this.SendPropertyChanging();
					this._CreationTime = value;
					this.SendPropertyChanged("CreationTime");
					this.OnCreationTimeChanged();
				}
			}
		}
		
		[Column(Storage="_LastModifiedTime", DbType="DateTime NOT NULL")]
		public System.DateTime LastModifiedTime
		{
			get
			{
				return this._LastModifiedTime;
			}
			set
			{
				if ((this._LastModifiedTime != value))
				{
					this.OnLastModifiedTimeChanging(value);
					this.SendPropertyChanging();
					this._LastModifiedTime = value;
					this.SendPropertyChanged("LastModifiedTime");
					this.OnLastModifiedTimeChanged();
				}
			}
		}
		
		[Association(Name="FK_DeckCard", Storage="_Deck", ThisKey="DeckId", OtherKey="Id", IsForeignKey=true)]
		public Deck Deck
		{
			get
			{
				return this._Deck.Entity;
			}
			set
			{
				Deck previousValue = this._Deck.Entity;
				if (((previousValue != value) 
							|| (this._Deck.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Deck.Entity = null;
						previousValue.Cards.Remove(this);
					}
					this._Deck.Entity = value;
					if ((value != null))
					{
						value.Cards.Add(this);
						this._DeckId = value.Id;
					}
					else
					{
						this._DeckId = default(int);
					}
					this.SendPropertyChanged("Deck");
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
	
	[Table(Name="Decks")]
	public partial class Deck : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _Id;
		
		private string _Name;
		
		private System.DateTime _CreationTime;
		
		private string _Description;
		
		private EntitySet<Card> _Cards;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIdChanging(int value);
    partial void OnIdChanged();
    partial void OnNameChanging(string value);
    partial void OnNameChanged();
    partial void OnCreationTimeChanging(System.DateTime value);
    partial void OnCreationTimeChanged();
    partial void OnDescriptionChanging(string value);
    partial void OnDescriptionChanged();
    #endregion
		
		public Deck()
		{
			this._Cards = new EntitySet<Card>(new Action<Card>(this.attach_Cards), new Action<Card>(this.detach_Cards));
			OnCreated();
		}
		
		[Column(Storage="_Id", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int Id
		{
			get
			{
				return this._Id;
			}
			set
			{
				if ((this._Id != value))
				{
					this.OnIdChanging(value);
					this.SendPropertyChanging();
					this._Id = value;
					this.SendPropertyChanged("Id");
					this.OnIdChanged();
				}
			}
		}
		
		[Column(Storage="_Name", DbType="NVarChar(4000) NOT NULL", CanBeNull=false)]
		public string Name
		{
			get
			{
				return this._Name;
			}
			set
			{
				if ((this._Name != value))
				{
					this.OnNameChanging(value);
					this.SendPropertyChanging();
					this._Name = value;
					this.SendPropertyChanged("Name");
					this.OnNameChanged();
				}
			}
		}
		
		[Column(Storage="_CreationTime", DbType="DateTime NOT NULL")]
		public System.DateTime CreationTime
		{
			get
			{
				return this._CreationTime;
			}
			set
			{
				if ((this._CreationTime != value))
				{
					this.OnCreationTimeChanging(value);
					this.SendPropertyChanging();
					this._CreationTime = value;
					this.SendPropertyChanged("CreationTime");
					this.OnCreationTimeChanged();
				}
			}
		}
		
		[Column(Storage="_Description", DbType="NVarChar(4000) NOT NULL", CanBeNull=false)]
		public string Description
		{
			get
			{
				return this._Description;
			}
			set
			{
				if ((this._Description != value))
				{
					this.OnDescriptionChanging(value);
					this.SendPropertyChanging();
					this._Description = value;
					this.SendPropertyChanged("Description");
					this.OnDescriptionChanged();
				}
			}
		}
		
		[Association(Name="FK_DeckCard", Storage="_Cards", ThisKey="Id", OtherKey="DeckId", DeleteRule="NO ACTION")]
		public EntitySet<Card> Cards
		{
			get
			{
				return this._Cards;
			}
			set
			{
				this._Cards.Assign(value);
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		
		private void attach_Cards(Card entity)
		{
			this.SendPropertyChanging();
			entity.Deck = this;
		}
		
		private void detach_Cards(Card entity)
		{
			this.SendPropertyChanging();
			entity.Deck = null;
		}
	}
}
#pragma warning restore 1591
